/*
MeeDocs - A Google Docs / Google Drive client for N9
Copyright 2012 Marcel D. Juhnke <marcel.juhnke@ovi.com>

This file is part of MeeDocs.

    MeeDocs is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    MeeDocs is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MeeDocs.  If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 1.1
import QtWebKit 1.0
import com.nokia.meego 1.0
import "storage.js" as Storage

Page {

    signal finished (string url)

    tools: loginTools


    PageHeader {
        id: pageHeader
        text: "Please login"
        anchors.top: parent.top
    }

    Flickable {
        anchors {
            top: pageHeader.bottom
            topMargin: 0
        }

        width: parent.width
        height: parent.height

        clip: true

        contentWidth: Math.max(parent.width,640)
        contentHeight: Math.max(parent.height,1200)
        pressDelay: 200

        WebView {
            id: webView
            anchors.fill: parent
            preferredHeight: height
            preferredWidth: Math.max(parent.width,640)
            url: "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=688932937241.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://docs.google.com/feeds/%20https://spreadsheets.google.com/feeds/%20https://docs.googleusercontent.com/";

            onLoadFinished: {
                loginDialog.finished(webView.title);
            }

        }
    }

    ToolBarLayout {
        id: loginTools
        visible: false
        ToolIcon {
            platformIconId: "toolbar-back"
            //anchors.left: (parent === undefined) ? undefined : parent.left
            onClicked: appWindow.pageStack.replace(mainPage)
        }
        ToolIcon {
            platformIconId: "toolbar-view-menu"
            //anchors.right: (parent === undefined) ? undefined : parent.right
            onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
        }
    }


}
